package com.framework.service.impl;

import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.framework.dao.AgentGradeDao;
import com.framework.entity.sys.SysAgentGrade;
import com.framework.service.AgentGradeService;
import com.framework.validator.Assert;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * @author wq
 */
@Service("agentGradeService")
public class AgentGradeServiceImpl extends ServiceImpl<AgentGradeDao, SysAgentGrade> implements AgentGradeService {

	@Override
	public SysAgentGrade queryGradeByAgentId(Long agentId) {
		SysAgentGrade s = new SysAgentGrade();
		s.setAgentId(agentId);
		return baseMapper.selectOne(s);
	}


	@Override
	public void updateAgentGrade(SysAgentGrade sysAgentGrade) {
		this.baseMapper.updateGradeById(sysAgentGrade);
	}

	@Override
	public SysAgentGrade checkByAgentId(Long agentId) {
		return this.baseMapper.checkByAgentId(agentId);
	}

	@Override
	public void insertAgentGrade(SysAgentGrade sysAgentGrade) {
		Assert.isNull(sysAgentGrade, "代理商等级信息不能为空");
		sysAgentGrade.setCreateTime(new Date());
		this.baseMapper.insert(sysAgentGrade);
	}

	@Override
	public List<Map<String, Object>> getRateList(Long agentId, Long deptId) {
		return baseMapper.getRateList(agentId,deptId);
	}
}
